<?php
function CleanText($value){
	return mysql_real_escape_string(htmlentities(stripslashes($value))); //Strips the code of anything that a hacker might try to do ;) Think smart!
}

function redirect_to($path){
	return header("location: $path");	
}

function get_id(){
	if(!isset($_GET['id'])){
		$id = 1;	
	}
	else{
		$id = (int)$_GET['id'];	
	}
	return $id;	
}

function get_page(){
	if(!isset($_GET['page'])){
		$page = 1;	
	}
	else{
		$page = (int)$_GET['page'];	
	}
	return $page;
}

function clear_array(&$array){
	foreach($array as $k => $v){
		$v = (string)$v;
		$v = trim($v);
		if(empty($v) or $v == '' or !isset($v)){
			unset($array[$k]);
		}
	}
	return $array;
}

function is_empty($value){
	$value = (string)$value;
	$value = trim($value);
	if(empty($value) or $value == '' or !isset($value)){
		return true;	
	}
	else{
		return false;	
	}
}

function strhex($string) {
  $hexstr = unpack('H*', $string);
  return array_shift($hexstr);
}

function hexstr($hexstr) {
	$hexstr = str_replace(' ', '', $hexstr);
	$hexstr = str_replace('\x', '', $hexstr);
	$retstr = pack('H*', $hexstr);
	return $retstr;
}

function ramka($act) {
	if ($act=='open') {
		echo "<div class='custmarg'><div class='mtopl'><div class='mtopr'><div class='mtop'></div></div></div><div class='ml'><div class='mr'><div class='mtext2' style='padding-left:4px;'>";
	}
	if ($act=='close') {
		echo "</div></div></div><div class='mbotl'><div class='mbotr'><div class='mbot'></div></div></div></div>";
	}
}

?>